﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title>预算编制页面</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap-table.css"/>
    <link rel="stylesheet" href="../css/bootstrap-table-fixed-columns.css"/>
    <script src="../js/jquery-1.11.0.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <script src="../js/bootstrap-table.js"></script>
    <script src="../js/bootstrap-table-fixed-columns.js"></script>
</head>
<style>
    .tab-pane {
        position: absolute;
        top: 42px;
        bottom: 0;
        right: 0;
        left: 0;
        overflow: auto;
    }
</style>
<script type="text/javascript">
    let databasic = [];
    let dataset = [];
    let datadetail = [];
    let baseschemadata = [];
    let setschemadata = [];
    let detailschemadata = [];
    const columns_sum = [{
        field: 'xh',
        title: '序号',
        align: 'center', // 居中显示
        width: 50,
    }, {
        field: 'bdbh',
        title: '表单编号',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bdmc',
        title: '表单名称',
        align: 'center', // 居中显示
        width: 200,
        events: {
            "click #btn_bdmc": function (e, value, row, index) {
                console.log("row", row);
            }
        },
        formatter: function (value, row, index) {
            return '<a href="#" id="btn_bdmc" style="text-decoration:none;">' + value + '</a>';
        }
    }, {
        field: 'bzzt',
        title: '状态',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'cz',
        title: '操作',
        align: 'center', // 居中显示
        width: 200,
        events: {
            "click #btn_fqsp": function (e, value, row, index) {
                console.log("row", row);
                if (row.bzzt === '未编制') {
                    window.parent.weaJs.alert("预算编制[" + row.count + "]条还未审核，汇总表不能进行审核操作");
                }
                if (row.bzzt === '编制中') {
                    window.parent.weaJs.alert("预算编制[" + row.count + "]条还未审核，汇总表不能进行审核操作");
                }
                if (row.bzzt === '已审核') {
                    var orders = getUrlParam("orders");
                    var arr = orders.split("_");
                    var jb = arr[0];
                    if(jb==='3' || jb==='4'){
                        if(jb==='3'){
                            var datas = createWorkflow('307',arr[3],'',row.taskid);
                            if(datas.totalcount<=0){
                                window.parent.weaJs.alert("发起审批失败！！！");
                            }else {
                                if(datas.successcount>0){
                                    window.parent.weaJs.alert("发起部门科目汇总审批流程成功");
                                }
                                if(datas.successcount>0){
                                    window.parent.weaJs.alert("发起部门科目汇总审批流程失败");
                                }
                            }
                            window.parent.weaJs.alert("只有部门或者科室才能发起审批！");
                        }else {
                            var datas = createWorkflow('306',arr[3],arr[4],row.taskid);
                            if(datas.totalcount<=0){
                                window.parent.weaJs.alert("发起审批失败！！！");
                            }else {
                                if(datas.successcount>0){
                                    window.parent.weaJs.alert("发起部门科目汇总审批流程成功");
                                }
                                if(datas.successcount>0){
                                    window.parent.weaJs.alert("发起部门科目汇总审批流程失败");
                                }
                            }
                        }
                    }else {
                        window.parent.weaJs.alert("只有部门或者科室才能发起审批！");
                    }

                }

            }
        },
        formatter: function (value, row, index) {
            return '<a href="#" id="btn_fqsp" style="text-decoration:none;">发起审批</a>';
        }
    }];
    const columns_basic = [{
        field: 'xz',
        checkbox: true,
        align: 'center', // 居中显示
        width: 50
    }, {
        field: 'kmbm',
        title: '科目编码',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'kmmc',
        title: '科目名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bdmc',
        title: '表单名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'zhbzsj',
        title: '最后编制时间',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bzzt',
        title: '状态',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'cz',
        title: '操作',
        align: 'center', // 居中显示
        width: 200,
        events: {
            "click #btn_sh": function (e, value, row, index) {
                if (row.bzzt === '编制中') {
                    var datas = eval('(' + submitTask(row.id, row.appid) + ')');
                    if (datas != null && datas.data != null) {
                        var data = datas.data;
                        if (data.success) {
                            window.parent.weaJs.alert("审核成功");
                            reloadTable("table_basic");
                        }
                    }
                } else {
                    window.parent.weaJs.alert("只有状态为编制中的任务，才能进行审核操作");
                }
            }
        },
        formatter: function (value, row, index) {
            return '<a href="#" id="btn_sh" style="text-decoration:none;">审核</a>';
        }
    }];
    const columns_set = [{
        field: 'xz',
        checkbox: true,
        align: 'center', // 居中显示
        width: 50
    }, {
        field: 'bdbh',
        title: '表单编号',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bdmc',
        title: '表单名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'zhbzsj',
        title: '最后编制时间',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bzzt',
        title: '状态',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'cz',
        title: '操作',
        align: 'center', // 居中显示
        width: 200,
        events: {
            "click #btn_sh": function (e, value, row, index) {
                if (row.bzzt === '编制中') {
                    var datas = eval('(' + submitTask(row.id, row.appid) + ')');
                    if (datas != null && datas.data != null) {
                        var data = datas.data;
                        if (data.success) {
                            window.parent.weaJs.alert("审核成功");
                            reloadTable("table_set");
                        }
                    }
                } else {
                    window.parent.weaJs.alert("只有状态为编制中的任务，才能进行审核操作");
                }
            }
        },
        formatter: function (value, row, index) {
            return '<a href="#" id="btn_sh" style="text-decoration:none;">审核</a>';
        }
    }];
    const columns_detail = [{
        field: 'xz',
        checkbox: true,
        align: 'center', // 居中显示
        width: 50
    }, {
        field: 'kmbm',
        title: '科目编码',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'kmmc',
        title: '科目名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bdmc',
        title: '表单名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'zhbzsj',
        title: '最后编制时间',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bzzt',
        title: '状态',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'cz',
        title: '操作',
        align: 'center', // 居中显示
        width: 200,
        events: {
            "click #btn_sh": function (e, value, row, index) {
                if (row.bzzt === '未编制') {
                    window.parent.weaJs.alert("未填报任务，不能进行审核操作");
                }
                if (row.bzzt === '编制中') {
                    var datas = eval('(' + submitTask(row.id, row.appid) + ')');
                    if (datas != null && datas.data != null) {
                        var data = datas.data;
                        if (data.success) {
                            window.parent.weaJs.alert("审核成功");
                            reloadTable("table_detail");
                            reloadTable("table_sum");
                        }
                    }
                } else {
                    window.parent.weaJs.alert("只有状态为编制中的任务，才能进行审核操作");
                }
            }
        },
        formatter: function (value, row, index) {
            return '<a href="#" id="btn_sh" style="text-decoration:none;">审核</a>';
        }
    }];
    const columns_schema = [{
        field: 'xz',
        checkbox: true,
        align: 'center', // 居中显示
        width: 50
    }, {
        field: 'bbh',
        title: '版本号',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'famc',
        title: '方案名称',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bznf',
        title: '编制年份',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'bzksyf',
        title: '编制开始月份',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'sfndcsbz',
        title: '是否年度初始编制',
        align: 'center', // 居中显示
        width: 200,
    }, {
        field: 'zdyybb',
        title: '指定引用版本',
        align: 'center', // 居中显示
        width: 200,
    }];

    $(document).ready(function () {
        init();
    });

    function init() {
        var orders = getUrlParam("orders");
        var bbh = getUrlParam("bbh");
        console.log("orders=" + orders);
        //汇总表
        $('#table_sum').bootstrapTable({
            method: 'get',
            url: '/api/weaBudgetWebApi/getSumTaskData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_sum,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    orders: orders,
                    bbh: bbh
                };
                return temp;
            },
        });
        //基准表
        $('#table_basic').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getBaseTaskData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_basic,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    kmbm: $("#kmbm_basic").val(),
                    bdmc: $("#bdmc_basic").val(),
                    bzzt: $("#bzzt_basic").val(),
                    orders: orders,
                    bbh: bbh
                };
                return temp;
            },
            onCheck: function (row) {
                databasic.push(row);
            },
            onUncheck: function (row) {
                for (var i = 0; i < databasic.length; i++) {
                    if (databasic[i].kmbm == row.kmbm) {
                        databasic.splice(i, 1);
                    }
                }
            },
            onCheckAll: function (row) {
                databasic = row;
            },
            onUncheckAll: function (row) {
                databasic = row;
            },

        });
        //套表
        $('#table_set').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getSetTaskData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_set,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    bdbh: $("#bdbh_set").val(),
                    bdmc: $("#bdmc_set").val(),
                    bzzt: $("#bzzt_set").val(),
                    orders: orders,
                    bbh: bbh
                };
                return temp;
            },
            onCheck: function (row) {
                dataset.push(row);
            },
            onUncheck: function (row) {
                for (var i = 0; i < dataset.length; i++) {
                    if (dataset[i].kmbm == row.kmbm) {
                        dataset.splice(i, 1);
                    }
                }
            },
            onCheckAll: function (row) {
                dataset = row;
            },
            onUncheckAll: function (row) {
                dataset = row;
            },
        });
        //明细表
        $('#table_detail').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getDetailTaskData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_detail,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    kmbm: $("#kmbm_detail").val(),
                    bdmc: $("#bdmc_detail").val(),
                    bzzt: $("#bzzt_detail").val(),
                    orders: orders,
                    bbh: bbh
                };
                return temp;
            },
            onCheck: function (row) {
                datadetail.push(row);
            },
            onUncheck: function (row) {
                for (var i = 0; i < datadetail.length; i++) {
                    if (datadetail[i].kmbm == row.kmbm) {
                        datadetail.splice(i, 1);
                    }
                }
            },
            onCheckAll: function (row) {
                datadetail = row;
            },
            onUncheckAll: function (row) {
                datadetail = row;
            },
        });

        //基准表编制方案
        $('#table_schema_base').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getSchemaData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            singleSelect: true,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_schema,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    bbh: bbh,
                };
                return temp;
            },
            onCheck: function (row) {
                baseschemadata.push(row);
            },
        });

        //套表编制方案
        $('#table_schema_set').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getSchemaData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            singleSelect: true,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_schema,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    bbh: bbh,
                };
                return temp;
            },
            onCheck: function (row) {
                setschemadata.push(row);

            },
        });

        //明细表编制方案
        $('#table_schema_detail').bootstrapTable({
            method: 'GET',
            url: '/api/weaBudgetWebApi/getSchemaData',
            cache: true, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            async: false,
            singleSelect: true,
            pagination: true,
            sortable: true,
            sortOrder: true,
            sidePagination: "client",
            pageNumber: 1,
            pageSize: 5,
            pageList: [5, 10, 25, 50],
            rowStyle: rowStyle,//通过自定义函数设置行样式
            columns: columns_schema,
            queryParams: function (params) { // 上传服务器的参数
                var temp = {
                    bbh: bbh,
                };
                return temp;
            },
            onCheck: function (row) {
                detailschemadata.push(row);
            },
        });

        $("#baseModal").on('show.bs.modal', function (e) {
            if (databasic.length <= 0) {
                window.parent.weaJs.alert("请选择一行数据!");
                e.preventDefault();
            }
        });
        $("#setModal").on('show.bs.modal', function (e) {
            if (dataset.length <= 0) {
                window.parent.weaJs.alert("请选择一行数据!");
                e.preventDefault();
            }
        });
        $("#detailModal").on('show.bs.modal', function (e) {
            if (datadetail.length <= 0) {
                window.parent.weaJs.alert("请选择一行数据!");
                e.preventDefault();
            }
        });
    }

    //隔行变色
    function rowStyle(row, index) {
        if (index % 2 === 0) {
            return {classes: 'defult'};
        } else {
            return {classes: 'info'};
        }
        return {};
    }

    //获取url地址参数
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]);
        return null; //返回参数值
    }

    //基准表搜索
    function search_basic() {
        $('#table_basic').bootstrapTable('refreshOptions', {
            url: '/api/weaBudgetWebApi/getBaseTaskData',
            pageNumber: 1
        });
    }

    //套表搜索
    function search_set() {
        $('#table_set').bootstrapTable('refreshOptions', {
            url: '/api/weaBudgetWebApi/getSetTaskData',
            pageNumber: 1
        });
    }

    //明细表搜索
    function search_detail() {
        $('#table_detail').bootstrapTable('refreshOptions', {
            url: '/api/weaBudgetWebApi/getDetailTaskData',
            pageNumber: 1
        });
    }

    //刷新表格（重新加载数据）
    function reloadTable(id) {
        $("#" + id).bootstrapTable('refreshOptions', {pageNumber: 1});  // pageNumber:1, 指定页码
    }

    //批量审核
    function batchCheck(dataList) {
        var counts = 0;
        dataList.map((item, index) => {
            if (item.bzzt === '编制中') {
                counts++;
            }
        });
        if (counts < dataList.length) {
            window.parent.weaJs.alert("只有状态为编制中的任务，才能进行批量审核操作");
        } else {
            var count = 0;
            dataList.map((item, index) => {
                var datas = eval('(' + submitTask(item.id, item.appid) + ')');
                if (datas != null && datas.data != null) {
                    var data = datas.data;
                    if (data.success) {
                        count++;
                    }
                }
            });
            window.parent.weaJs.alert("批量审核总数量:[" + dataList.length + "],成功数量:[" + count + "],失败数量:[" + (dataList.length - count) + "]");
        }
    }

    //基准表批量审核
    function batchCheckBasic() {
        if (databasic.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            console.log("databasic", databasic);
            batchCheck(databasic);
            reloadTable("table_basic");
            databasic = [];
        }
    }

    //套表批量审核
    function batchCheckSet() {
        if (dataset.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            console.log("dataset", dataset);
            batchCheck(dataset);
            reloadTable("table_set");
            dataset = [];
        }
    }

    //明细表批量审核
    function batchCheckDetail() {
        if (datadetail.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            console.log("datadetail", datadetail);
            batchCheck(datadetail);
            reloadTable("table_detail");
            datadetail = [];
        }
    }

    //取消批量审核
    function batchUnCheck(dataList) {
        var counts = 0;
        dataList.map((item, index) => {
            if (item.bzzt === '已审核') {
                counts++;
            }
        });
        console.log("counts=" + counts + ",length=" + dataList.length);
        if (counts < dataList.length) {
            window.parent.weaJs.alert("只有状态为已审核的任务，才能进行取消操作");
        } else {
            var count = 0;
            dataList.map((item, index) => {
                var data = eval('(' + undoTask(item.id) + ')');
                if (data.api_status) {
                    count++;
                }
            });
            window.parent.weaJs.alert("取消审核总数量:[" + dataList.length + "],成功数量:[" + count + "],失败数量:[" + (dataList.length - count) + "]");
        }
    }

    //基准表取消批量审核
    function batchUnCheckBasic() {
        if (databasic.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            batchUnCheck(databasic);
            reloadTable("table_basic");
            databasic = [];
        }
    }

    //套表取消批量审核
    function batchUnCheckSet() {
        if (dataset.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            batchUnCheck(dataset);
            reloadTable("table_set");
            dataset = [];
        }
    }

    //明细表取消批量审核
    function batchUnCheckDetail() {
        if (datadetail.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            batchUnCheck(datadetail);
            reloadTable("table_detail");
            datadetail = [];
        }
    }

    //引用历史版本
    function formConfirm(dataList,schemadata) {
        var jsonArr = [];
        dataList.find(item => {
            if (schemadata[0].sfndcsbz === "否") {
                console.log("Version=" + schemadata[0].bbh);
                var lastVersion = getLastVersion(schemadata[0].bbh);
                console.log("lastVersion=" + lastVersion);
                var jsondata = {id: item.id, appid: item.appid, bbh: lastVersion};
                jsonArr.push(jsondata);
            } else {
                console.log("Version=" + schemadata[0].zdyybb);
                var jsondata = {id: item.id, appid: item.appid, bbh: schemadata[0].zdyybb};
                jsonArr.push(jsondata);
            }
        });
        var data = eval('(' + refHisVersion(jsonArr) + ')');
        window.parent.weaJs.alert("引用历史版本总数量:[" + data.counts + "],成功数量:[" + data.successCount + "],失败数量:[" + data.failureCount + "]");
    }

    //基准表引用历史版本
    function baseformConfirm() {
        if (databasic.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            if (baseschemadata.length > 0) {
                console.log("databasic", databasic);
                console.log("baseschemadata", baseschemadata);
                formConfirm(databasic,baseschemadata);
                reloadTable("table_basic");
                databasic = [];
            } else {
                window.parent.weaJs.alert("请选择一行数据!");
            }
        }
    }

    //套表引用历史版本
    function setformConfirm() {
        if (dataset.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            if (setschemadata.length > 0) {
                console.log("dataset", dataset);
                console.log("setschemadata", setschemadata);
                formConfirm(dataset,setschemadata);
                reloadTable("table_set");
                dataset = [];
            } else {
                window.parent.weaJs.alert("请选择一行数据!");
            }
        }
    }

    //明细表引用历史版本
    function detailformConfirm() {
        if (datadetail.length <= 0) {
            window.parent.weaJs.alert("请选择一行数据!");
        } else {
            console.log("detailschemadata", detailschemadata);
            if (detailschemadata.length > 0) {
                console.log("datadetail", datadetail);
                console.log("detailschemadata", detailschemadata);
                formConfirm(datadetail,detailschemadata);
                reloadTable("table_detail");
                datadetail = [];
            } else {
                window.parent.weaJs.alert("请选择一行数据!");
            }
        }
    }

    //获取提交任务数据
    function getTaskData(taskid, appid) {
        var datas = "";
        $.ajax({
            async: false,
            url: '/api/weaBudgetWebApi/getTaskData',
            data: {taskid: taskid, appid: appid},
            type: "get",
            success: function (data) {
                datas = data;
            }, error: function (e) {
            }
        });
        return datas;
    }

    //获取提交任务数据
    function getNodeAndUser(taskid) {
        var datas = "";
        $.ajax({
            async: false,
            url: '/api/weaBudgetWebApi/getNodeAndUser',
            data: {taskid: taskid},
            type: "get",
            success: function (data) {
                datas = data;
            }, error: function (e) {
            }
        });
        return datas;
    }

    //获取提交任务数据
    function submitTask(taskid, appid) {
        var result = "";
        var userinfo = eval('(' + getNodeAndUser(taskid) + ')');
        var defaultValue = {
            hrm: {name: userinfo.name, id: userinfo.userid},
            datetime: userinfo.datetime, time: userinfo.time
        };
        console.log("defaultValue", defaultValue);
        var datas = getTaskData(taskid, appid);
        var param = {
            nodeid: userinfo.nodeid, taskid: taskid, userid: '', datas: datas,
            combineSheetHasData: {}, deletedRows: {}, defaultValue: defaultValue
        };
        console.log("param", param);
        $.ajax({
            async: false,
            url: '/api/edc/task/submitTask',
            data: param,
            type: "post",
            success: function (data) {
                result = data;
            }, error: function (e) {
            }
        });
        return result;
    }

    //获取撤回任务数据
    function undoTask(taskid) {
        var result = "";
        var userinfo = eval('(' + getNodeAndUser(taskid) + ')');
        $.ajax({
            async: false,
            url: '/api/edc/task/undoTask',
            data: {nodeid: userinfo.nodeid, taskid: taskid, userid: ''},
            type: "get",
            success: function (data) {
                result = data;
            }, error: function (e) {
            }
        });
        return result;
    }

    //引用指定版本号
    function refHisVersion(jsonArr) {
        var datas = "";
        $.ajax({
            async: false,
            url: '/api/weaBudgetWebApi/refHisVersion',
            data: {jsonArr: JSON.stringify(jsonArr)},
            type: "get",
            success: function (data) {
                datas = data;
            }, error: function (e) {
            }
        });
        return datas;
    }

    //获取上一个版本号
    function getLastVersion(bbh) {
        var lastVersion = "";
        $.ajax({
            async: false,
            url: '/api/weaBudgetWebApi/getLastVersion',
            data: {bbh: bbh},
            type: "get",
            dataType: "json",
            success: function (data) {
                lastVersion = data.lastVersion;
            }, error: function (e) {
            }
        });
        return lastVersion;
    }
    //创建流程
    function createWorkflow(workflowid,bmbm,ksbm,taskids) {
        var datas = "";
        $.ajax({
            async: false,
            url: '/api/weaBudgetWebApi/createWorkflow',
            data: {workflowid: workflowid,bmbm:bmbm,ksbm:ksbm,taskids:taskids},
            type: "get",
            success: function (data) {
                datas = data;
            }, error: function (e) {
            }
        });
        return datas;
    }


</script>
<body>
<ul class="nav nav-tabs" style="background-color: cyan;">
    <li class="active"><a href="#home" data-toggle="tab"><h5>汇总表</h5></a></li>
    <li><a href="#profile" data-toggle="tab"><h5>明细表</h5></a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane active" id="home">
        <div class="jumbotron jumbotron-fluid">
            <div class="row">
                <h4 style="text-align: center">汇总表</h4>
                <table id="table_sum" class="text-info"></table>
                <div style="margin-top: 5px">
                    <h4 style="text-align: center">基准表</h4>
                    <input type="text" id="kmbm_basic" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索科目编码">
                    <input type="text" id="bdmc_basic" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索表单名称">
                    <input type="text" id="bzzt_basic" class="form-control" style="width: 100px; float: left"
                           placeholder="搜索状态">
                    <span style="float: left"><a href="#" class="btn btn-default" type="button"
                                                 role="button" onclick="search_basic()">搜索</a></span>
                    <div class="btn-group" style="float: right">
                        <a href="#" type="button" class="btn btn-info" role="button" data-toggle="modal"
                           data-target="#baseModal">引用历史版本</a>
                        <a href="#" type="button" class="btn btn-info" role="button"
                           onclick="batchCheckBasic()">批量审核</a>
                        <a href="#" type="button" class="btn btn-info" role="button" onclick="batchUnCheckBasic()">取消批量审核</a>
                    </div>
                    <table id="table_basic" class="text-info"></table>
                </div>
                <div style="margin-top: 5px">
                    <h4 style="text-align: center">套表</h4>
                    <input type="text" id="bdbh_set" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索表单编号">
                    <input type="text" id="bdmc_set" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索表单名称">
                    <input type="text" id="bzzt_set" class="form-control" style="width: 100px; float: left"
                           placeholder="搜索状态">
                    <span style="float: left"><a href="#" class="btn btn-default" type="button"
                                                 role="button" onclick="search_set()">搜索</a></span>
                    <div class="btn-group" style="float: right">
                        <a href="#" type="button" class="btn btn-info" role="button" data-toggle="modal"
                           data-target="#setModal">引用历史版本</a>
                        <a href="#" type="button" class="btn btn-info" role="button" onclick="batchCheckSet()">批量审核</a>
                        <a href="#" type="button" class="btn btn-info" role="button"
                           onclick="batchUnCheckSet()">取消批量审核</a>
                    </div>
                    <table id="table_set" class="text-info"></table>
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="profile">
        <div class="jumbotron jumbotron-fluid">
            <div class="row">
                <div style="margin-top: 5px">
                    <h4 style="text-align: center">明细表</h4>
                    <input type="text" id="kmbm_detail" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索科目编码">
                    <input type="text" id="bdmc_detail" class="form-control" style="width: 120px; float: left"
                           placeholder="搜索表单名称">
                    <input type="text" id="bzzt_detail" class="form-control" style="width: 100px; float: left"
                           placeholder="搜索状态">
                    <span style="float: left"><a href="#" class="btn btn-default" type="button"
                                                 role="button" onclick="search_detail()">搜索</a></span>
                    <div class="btn-group" style="float: right">
                        <a href="#" type="button" class="btn btn-info" role="button" data-toggle="modal"
                           data-target="#detailModal">引用历史版本</a>
                        <a href="#" type="button" class="btn btn-info" role="button"
                           onclick="batchCheckDetail()">批量审核</a>
                        <a href="#" type="button" class="btn btn-info" role="button" onclick="batchUnCheckDetail()">取消批量审核</a>
                    </div>
                    <table id="table_detail" class="text-info"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 基准表弹出框（Modal） -->
<div class="modal fade" id="baseModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px">
        <div class="modal-content">
            <div class="modal-header" style="height: 40px">
                <h5 class="modal-title">编制方案</h5>
            </div>
            <div class="modal-body">
                <div>
                    <table id="table_schema_base" class="text-info"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-info" onclick="baseformConfirm()" data-dismiss="modal">确认
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 套表弹出框（Modal） -->
<div class="modal fade" id="setModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px">
        <div class="modal-content">
            <div class="modal-header" style="height: 40px">
                <h5 class="modal-title">编制方案</h5>
            </div>
            <div class="modal-body">
                <div>
                    <table id="table_schema_set" class="text-info"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-info" onclick="setformConfirm()" data-dismiss="modal">确认
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 明细表弹出框（Modal） -->
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width: 800px">
        <div class="modal-content">
            <div class="modal-header" style="height: 40px">
                <h5 class="modal-title">编制方案</h5>
            </div>
            <div class="modal-body">
                <div>
                    <table id="table_schema_detail" class="text-info"></table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-info" onclick="detailformConfirm()" data-dismiss="modal">确认
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
</body>
</html>